package com.wnn.demo.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.pagehelper.PageHelper;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Result extends PageHelper {

    private boolean success;
    private Integer code;
    private String msg;
    private Long count;
    private Object data;


    public  Result( ResultCode code){
        this.success = code.success;
        this.code = code.code;
        this.msg = code.msg;
    }

    public Result( boolean success,Integer code,String msg){
        this.success = success;
        this.code = code;
        this.msg = msg;
    }

    public Result(ResultCode code,Object data){
        this.success = code.success;
        this.code = code.code;
        this.msg = code.msg;
        this.data = data;
    }
    public Result( ResultCode code,Long count,Object data){
        this.success = code.success;
        this.code = code.code;
        this.msg = code.msg;
        this.count = count;
        this.data = data;
    }


    public static Result ok(){ return new Result(ResultCode.OK); }

    public static Result failure(){
        return new Result(ResultCode.FALSE);
    }

    public static Result error(){
        return new Result(ResultCode.ERROR);
    }

}
